#include "operatewidget.h"
#include <QStackedWidget>
#include <QHBoxLayout>

OperateWidget::OperateWidget(QWidget *parent)
    : QWidget{parent}
{
    resize(1400, 900);

    m_list_widget = new QListWidget(this);
    m_list_widget->addItem("文件");
    m_list_widget->addItem("好友");

    m_friend = new Friend;
    m_book = new Book;

    QStackedWidget* m_stack_widget = new QStackedWidget;
    m_stack_widget->addWidget(m_book);
    m_stack_widget->addWidget(m_friend);

    // m_stack_widget->setCurrentWidget(m_book);  //设置默认的显示窗口

    QHBoxLayout* all_hl = new QHBoxLayout;
    all_hl->addWidget(m_list_widget);
    all_hl->addWidget(m_stack_widget);

    setLayout(all_hl);

    connect(m_list_widget, &QListWidget::currentRowChanged,
            m_stack_widget, &QStackedWidget::setCurrentIndex);
}

OperateWidget &OperateWidget::getInstance()
{
    static OperateWidget ret;
    return ret;
}

Friend *OperateWidget::getFriend()
{
    return m_friend;
}

Book *OperateWidget::get_book()
{
    return m_book;
}
